package cn.cjp.m3d27;

import java.util.LinkedList;

public class cLinkedList {

    public static void main(String[] args) {
        LinkedList<String> linkedList = new LinkedList<>();
        linkedList.add("a");
        linkedList.add("b");
        linkedList.add("c");
        System.out.println(linkedList);
        System.out.println("================");

        //插入到集合开头
        linkedList.addFirst("a0");
        linkedList.push("a00");
        System.out.println(linkedList);
        System.out.println("================");

        //插入到末尾
        linkedList.addLast("c0");
        linkedList.add("c00");
        System.out.println(linkedList);
        System.out.println("================");

        //获取元素
        String str1 = linkedList.getFirst();
        String str2 = linkedList.getLast();

        //移除并返回被移除元素
        linkedList.pop();  //第一个元素
        String str3 = linkedList.removeFirst();
        String str4 = linkedList.removeLast();
        System.out.println(linkedList);
        System.out.println("================");
    }
}
